package com.dyh.quickdemo.GoodsRules;



import java.util.ArrayList;
import java.util.List;
import java.util.function.Function;

/*
@Author=Joey Wheeler
@Date=2021/3/6 10:43
*/
public class Rule$2Builder<T,V1,V2> extends BaseRuleBuilder<Rule$2<T,V1,V2>>{

    private List<CheckerAndTip<Checker$2<V1,V2>>> checkerAndTips;

    public static <T,V1,V2> Rule$2Builder<T,V1,V2> when(Function<T,V1> mapper1,Function<T,V2> mapper2){
        Rule$2Builder builder = new Rule$2Builder();
        builder.mappers = new Function[]{mapper1,mapper2};
        builder.checkerAndTips = new ArrayList();
        return builder;
    }


    public Rule$2Builder<T,V1,V2> must(Checker$2<V1,V2> checker, String tip){
        this.checkerAndTips.add(new CheckerAndTip(checker,tip));
        return this;
    }

    @Override
    public  Rule$2<T, V1,V2> build() {
        return new Rule$2<>(
                (Function<T, V1>) mappers[0],
                (Function<T,V2>)mappers[1],
                checkerAndTips);
    }

}
